//
//  TextFieldOffsetPlaceHolder.swift
//  AirlineReservation
//
//  Created by Kevin on 2019/12/28.
//  Copyright © 2019 Kevin. All rights reserved.
//

import UIKit

class TextFieldOffsetPlaceHolder: UITextField {

    override func placeholderRect(forBounds bounds: CGRect) -> CGRect {
        return CGRect(x: 0, y: 0, width: bounds.size.width, height: bounds.size.height)
    }
    
    override func drawPlaceholder(in rect: CGRect) {
        // 弱提示文本
        let title = placeholder ?? ""
        attributedPlaceholder = NSAttributedString(string: title, attributes: [.foregroundColor : UIColor.lightGray])
        // 必须设置在前，否则不生效
        super.drawPlaceholder(in: CGRect(x: MARGIN * 5, y: 0, width: bounds.size.width, height: bounds.size.height))
    }
}
